﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace video
{
    class Tool
    {
        /// <summary>
        /// 获取当前时间戳
        /// </summary>
        /// <returns></returns>
        public static string GetTimeStamp()
        {
            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalSeconds).ToString();
        }

        /// <summary>
        /// 获取实际要写入的数组长度
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static int GetByteArrayLength(byte[] bytes)
        {
            int i;
            for (i = 0; i < bytes.Length; i++)
            {
                if (bytes[i] == 0)
                {
                    break;
                }
            }
            return i > bytes.Length ? bytes.Length : i;
        }
    }
}
